package proxy.dynamic.v6;

import org.springframework.cglib.proxy.Enhancer;
import org.springframework.cglib.proxy.MethodInterceptor;
import org.springframework.cglib.proxy.MethodProxy;

import java.lang.reflect.Method;

public class Test {

    public static void main(String[] args) {
        Enhancer enhancer = new Enhancer();
        enhancer.setSuperclass(CalcService.class);
        enhancer.setCallback((MethodInterceptor) (o, method, objects, methodProxy) -> {
            return execute();
        });
        CalcService<String, String, String> calcService = (CalcService) enhancer.create();
        System.out.println(calcService.execute("zhang", "wang"));

    }

    public static Object execute(){
        return "ZHANGSAN";
    }
}
